
Page({
    data: {
         list:[1,2,3,4]
    },
    onLoad:function(opt){
      var userInfo= wx.getStorageSync('userInfo');
        this.setData({
            userInfo:userInfo,
            type:opt.type
        })
   
    },
    onShow:function(){
       var _self=this;
        wx.request({
            url:getApp().globalData.baseUrl+'/addr/list',
            method:"get",
            header:{
               'openid':this.data.userInfo.openid, //公用请求头
               'content-type': 'application/json'
            },
            data:{openid:this.data.userInfo.openid},
            success: function(res) {
              if (res.data.code==200) {
                for(var i=0;i<res.data.obj.length;i++){
                  if (res.data.obj[i].del=='1') {
                      _self.setData({
                        selectId:res.data.obj[i].id
                      })
                  }
                }
                _self.setData({
                  list:res.data.obj
                })
              }
            console.log(res)  
            
         }
       })
    },
    choose:function(e){
      if (this.data.type=='mine') {
        return
      }else{
        console.log('选中')
       this.setData({
        selectId:e.currentTarget.dataset.item.id
       })
       wx.setStorageSync('shopAddress',e.currentTarget.dataset.item);

       wx.navigateBack({
        delta: 1
       })
      }
      
    },
    toAddress:function(e){
      console.log('修改')
      console.log(e)
       wx.navigateTo({
            url:'/pages/addAddress/addAddress?code='+e.currentTarget.dataset.code
        })
    }
});